package com.jvup.gameshow.controller;

import android.text.InputType;
import android.view.View;

import com.jvup.common.support.base.EventController;
import com.jvup.gameshow.R;
import com.jvup.gameshow.activity.LoginGuideActivity;
import com.jvup.gameshow.model.viewModel.impl.LoginGuideViewModel;
import com.jvup.gameshow.view.CompoundEventEditText;
import com.jvup.gameshow.view.CompoundEventEditText.EventDrawable;

public class LoginGuideController extends EventController<LoginGuideActivity> {

    private LoginGuideViewModel viewModel;

    public LoginGuideController(LoginGuideActivity activity) {
        super(activity);
    }

    @Override
    protected void bindView() {
//        owner.viewDataBinder().setVariable(BR.loginGuideController, this);
        owner.viewDataBinder().setLoginGuideController(this);
    }

    public void setViewModel(LoginGuideViewModel viewModel){
        this.viewModel = viewModel;
    }

    public boolean compoundEventPlaintextBtnOnClick(CompoundEventEditText view, EventDrawable eventDrawable) {
        int inputType = view.getInputType();

        int visiblePassword = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
        int invisiblePassword = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;

        if(inputType != visiblePassword) {
            view.setInputType(visiblePassword);
            eventDrawable.setDrawableResId(R.drawable.app_compound_icon_pwd_plaintext);
        } else {
            view.setInputType(invisiblePassword);
            eventDrawable.setDrawableResId(R.drawable.app_compound_icon_pwd_ciphertext);
        }
        view.setSelection(view.getText().length());
        return true;
    }

    /**
     * 返回按钮事件
     * @param view
     */
    public void goBackBtnOnClick(View view) {
        owner.finish();
    }

    /**
     * 手机登录按钮事件
     * @param view
     */
    public void phoneLoginBtnOnClick(View view) {

    }

    /**
     * 跳转注册页面按钮事件
     * @param view
     */
    public void gotoRegisterBtnOnClick(View view){
        viewModel.toggleTo(false);
    }

    /**
     * 忘记密码按钮事件
     * @param view
     */
    public void forgetPasswordBtnOnClick(View view){

    }

    /**
     * 发送验证码按钮事件
     */
    public void sendVerifyCodeBtnOnClick(View view){

    }

    /**
     * 手机注册按钮事件
     * @param view
     */
    public void phoneRegisterBtnOnClick(View view){
        viewModel.register();
    }

    /**
     * 跳转登录页面按钮事件
     * @param view
     */
    public void gotoLoginBtnOnClick(View view){
        viewModel.toggleTo(true);
    }


    /**
     * 微信登录按钮事件
     * @param view
     */
    public void weChatButtonOnClick(View view){

    }

    /**
     * QQ登录按钮事件
     * @param view
     */
    public void qqButtonOnClick(View view){

    }

    /**
     * 用户协议单击事件
     * @param view
     */
    public void userAgreementOnClick(View view){

    }

    /**
     * 隐私协议单击事件
     * @param view
     */
    public void privacyAgreementOnClick(View view){

    }

}
